Repository navigation
Fix: delete an in-memory context under the key it was stored as - #336
Merged
briankane merged 1 commit intoNov 21, 2026
Merged
Conversation
DeleteInMemoryContext built its key as "workflow-<app>-context", while every write and read goes through contextKey(name, namespace), which is "<namespace>/workflow-<app>-context". The keys could never match, so the delete was a no-op and the context of a deleted Application stayed in memory for the life of the controller. Take the namespace the same way GetInMemoryContext does and build the key with contextKey and generateStoreName. The KubeVela call site has to pass app.Namespace after it bumps this repo. Signed-off-by: Marcus Beauregard <marcus.beauregard.developer@gmail.com>
marcus-beauregard
requested review from
FogDong,
Somefive,
anoop2811,
briankane,
jerrinfrancis,
jguionnet,
leejanee,
roguepikachu and
wonderflow
as code owners
November 21, 2026 08:18
briankane
approved these changes
Nov 21, 2026
This was referenced Nov 21, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #336 +/- ##
===========================================
+ Coverage 62.49% 80.64% +18.15%
===========================================
Files 62 88 +26
Lines 4415 7053 +2638
===========================================
+ Hits 2759 5688 +2929
- Misses 1324 1365 +41
+ Partials 332 0 -332
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
Fixes #333
DeleteInMemoryContextbuilt its key asworkflow-<app>-context, but every write and read goes throughcontextKey, which is<namespace>/workflow-<app>-context(getKey, storage.go:39). The two could never match, so the delete was a no-op and the context of a deleted Application stayed in memory for the life of the controller wheneverEnableInMemoryContextwas on.DeleteInMemoryContext(appName)now takes(appName, namespace)and builds the key withcontextKey(generateStoreName(appName), namespace), the same helpers the store writes with.fmtis no longer needed in the file.TestDeleteInMemoryContext: deleting removes that namespace's context, leaves another namespace's alone, defaults an empty namespace the same way reads and writes do (both directions), and is a no-op for a context that was never stored.Two things worth your attention:
application_controller.gocallsMemStore.DeleteInMemoryContext(app.Name)); that repo has to passapp.Namespaceafter it bumps this module. The issue says the same, and a variadic or an extra method would leave the broken no-op delete reachable.pkg/context/storage_test.gostill importedgithub.com/crossplane/crossplane-runtime/pkg/testafter the v2 dependency bump, sogo test ./pkg/context/fails to build on main right now withmissing go.sum entry for module providing package github.com/crossplane/crossplane-runtime/pkg/test. I changed that one line to/v2/pkg/test; otherwise the package's tests, including the new one, cannot run. Nothing else from the v1 module is imported anywhere in the repo (git grep crossplane-runtime/pkg), so this is the only stale import.I have:
make reviewablefor the packages I touched:gofmt -l pkg/contextclean,go vet ./pkg/context/clean. I did not run the full target because it regenerates manifests and CRDs unrelated to this change.backport release-x.ylabels.How has this code been tested
go test ./pkg/context/— ok, all tests in the package pass.contextKey(generateStoreName(app.Name), ""), namespace dropped) makes the new test fail atstorage_test.go:94with "delete should remove the stored context"; the fix makes it pass. So the test fails for the reason the issue describes and not only for the signature.MemStoreis package-global and the call site lives in the other repo.Special notes for your reviewer
The namespace argument is deliberately explicit rather than defaulted inside the delete: the store already treats
""asdefault, and the test pins both directions, so a caller that forgetsapp.Namespacegetsdefault— which is whatNewContextwrites for a cluster-scoped or default-namespace Application.Summary by cubic
Fixes in-memory context deletion so the stored context of a deleted Application is actually removed instead of remaining in memory for the life of the controller.
DeleteInMemoryContextbuilt its key asworkflow-<app>-context, but every read and write uses<namespace>/workflow-<app>-context; the keys never matched, so the delete was a no-op.(appName, namespace)and builds the key with the same helpers reads and writes use. This is a breaking change for callers, who must passapp.Namespace.TestDeleteInMemoryContextcovering per-namespace deletion, empty-namespace defaulting in both directions, and no-ops on never-stored contexts.crossplane-runtimev1 import inpkg/context/storage_test.gothat brokego test ./pkg/context/.Written for commit fda4d75. Summary will update on new commits.